package com.factory._01simple;

import com.factory.entity.Apple;
import com.factory.entity.Grape;
import com.factory.entity.Strawberry;
import com.factory.exception.BadFruitException;
import com.factory._01simple.inter.Fruit;

/**
 * @author Qinye
 * @date 2023/8/10 22:44
 */
public class FruitGardener {
    public static Fruit factory(String which) throws BadFruitException {

        if (which.equalsIgnoreCase("apple")) {
            return new Apple();
        } else if (which.equalsIgnoreCase("strawberry")) {
            return new Strawberry();
        } else if (which.equalsIgnoreCase("grape")) {
            return new Grape();
        } else {
            throw new BadFruitException("bad fruit request");
        }
    }
}
